<script setup>
import { appStockListQuery } from "@/services/cashier";
import { onLoad, onReady, onShow } from "@dcloudio/uni-app";
import { nextTick, ref, watch, onMounted, onUnmounted } from "vue";
// import { useWebSocket } from "@/utils/socket/useWebSocket";

// const socketUrl = ref(
//   "wss://test-retail.yibaitao.cn/app/message/bus?X-Auth-Token=" +
//     uni.getStorageSync("X-Auth-Token")
// ); // 确保使用正确的WebSocket URL

// websocket 通讯
import {
  getWebSocket,
  websoket,
  webSoketInit,
  closeSocket,
  sendMessage,
} from "@/utils/socket/socket.js";

// 判断当前视口大小
onLoad((options) => {
  webSoketInit();
});
onReady(() => {
  // 获取websocket对象
  let ws = getWebSocket();

  // 接受后端消息触发
  ws.value.onMessage((e) => {
    console.log("接受后端消息", e);
  });
});
</script>

<template>
  <view class="bg">
    <up-navbar
      bgColor="rgba(255, 255, 255, 0)"
      @rightClick="rightClick"
      :autoBack="true"
      :safeAreaInsetTop="true"
      :fixed="true"
      :placeholder="true"
      :leftText="'返回'"
    >
      <template #right> </template>
      <template #center>
        <text
          class="text-white"
          style="
            font-weight: 500;
            font-size: 34rpx;
            color: #000000;
            line-height: 48rpx;
            text-align: center;
          "
          >销售排行</text
        ></template
      >
    </up-navbar>
    <view>数据: {{ messages }}</view>
  </view>
</template>

<style lang="scss" scoped>
@import "index.scss";
</style>
